package com.sino.second.dao.hibernate;

import java.util.Collection;
import java.util.List;

import com.sino.second.dao.ISmsendDAO;
import com.sino.util.page.AbstractPagerManager;
import com.sino.util.page.PagerModel;

public class SmsDAO extends AbstractPagerManager implements ISmsendDAO {

	public PagerModel findExpertsSmsList(String hqlWhere) {
		String str_SQL = "from TblExpertmessage tem where '1'='1' ";
		if (hqlWhere.length() > 1) {
			str_SQL += " and " + hqlWhere;
		}
		return this.searchPaginated(str_SQL);

	}

	// xyw 根据FBh查找专家发送信息
	public List findExpertsSmsListByFBh(int FBh, String hqlWhere) {
		String str_SQL = "from TblExpertmessage tem where tem.tblZhuanjiarukuxinxibiao.FBh=?";
		if (hqlWhere.length() > 1) {
			str_SQL += " and " + hqlWhere;
		}
		return this.getHibernateTemplate().find(str_SQL, new Object[] { FBh });
	}

	public PagerModel findXmSmsList(String hqlWhere) {
		String str_SQL = "from TblMessage tem where '1'='1' ";
		if (hqlWhere.length() > 1) {
			str_SQL += " and " + hqlWhere;
		}
		return this.searchPaginated(str_SQL);
	}

	// xyw 根据专家ID查找专家发送信息
	public List findXmSmsListByXmId(String zlid, String hqlWhere) {
		String str_SQL = "from TblMessage tem where tem.basicinfo.zlid=?";
		if (hqlWhere.length() > 1) {
			str_SQL += " and " + hqlWhere;
		}
		return this.getHibernateTemplate().find(str_SQL, new Object[] { zlid });
	}

	// xyw保存发送信息记录
	public void saveSmsCollection(Collection o) {
		this.getHibernateTemplate().saveOrUpdateAll(o);
	}

}
